const UserModel = require('../model/userModel')

const userDao = {
    getUserListDao: async () => {
        try {
            let userList = await UserModel.findAll({
                where: {
                    name: '张三'
                }
            })
            return userList
        } catch (error) {
            console.log(error)
        }
    },
    delUserLoginDao:  async(req) => {
        try {
            let { account, password} = req
            let res = await UserModel.findOne({
                where:{
                    account:account,
                    password:password
                }
            })
            //至于数据库连接查询
            if(!res){
                return {
                    status:201,
                    msg:"用户名或密码错误"
                }
            }
            return res
        } catch (error) {
            
        }
    },
    addUserAvatorDao: (req) => {
        let {url ,id} = req
        UserModel.update({avatar:url},{
            where:{
                id:id
            }
        })
        return {
            status:200,
            mas:"上传成功",
            url:url
        }
    } 
}

module.exports = userDao